<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
<ui:define name="content">
 <h:outputScript library="js" name="radio.js" />


<div align="center">
		<h:form id="search">

			<h:panelGrid columns="3">
		    	
		    		<h:outputLabel for="teamA: " value="Team A:"/>
		    		<h:inputText id="teamA" value="#{searchBean.gameToSearch.teamA}" required="false" requiredMessage="Please insert team A"/>	
		    		<h:message for="teamA" style="background-color:red;"/>
		    		
		    		
		    		<h:outputLabel for="teamB" value="Team B"/>
		    		<h:inputText id="teamB" value="#{searchBean.gameToSearch.teamB}" required="false" requiredMessage="Please insert team B"/>
		    		<h:message for="teamA" style="background-color:red;"/>
		    				    	
		    	</h:panelGrid>	
		    	<h:panelGrid columns="6">
		    	
		    		<h:outputLabel value="Data:"/>
					<h:selectOneMenu value="#{searchBean.gameToSearch.year}">
		    			<f:selectItems value="#{searchBean.gameToSearch.years}"/>
		    		</h:selectOneMenu>
		    		<h:selectOneMenu value="#{searchBean.gameToSearch.month}">
		    			<f:selectItems value="#{searchBean.gameToSearch.months}"/>
		    		</h:selectOneMenu>
		    		<h:selectOneMenu value="#{searchBean.gameToSearch.day}">
		    			<f:selectItems value="#{searchBean.gameToSearch.days}"/>
		    		</h:selectOneMenu>
		    		
		    				    	
		    	</h:panelGrid>	
		    	<h:panelGrid columns="6">
		    	
		    		<h:outputLabel value="Time:"/>
					<h:selectOneMenu value="#{searchBean.gameToSearch.hour}">
		    			<f:selectItems value="#{searchBean.gameToSearch.hours}"/>
		    		</h:selectOneMenu>
		    		<h:selectOneMenu value="#{searchBean.gameToSearch.minute}">
		    			<f:selectItems value="#{searchBean.gameToSearch.minutes}"/>
		    		</h:selectOneMenu>
		    				    				    	
		    	</h:panelGrid>
		    		
		    		<h:selectOneMenu value="#{searchBean.gameToSearch.stadium}">
		    			<f:selectItems value="#{searchBean.gameToSearch.stadiums}"/>
		    		</h:selectOneMenu>
		    		
		    		<h:selectOneMenu value="#{searchBean.gameToSearch.city}">
		    			<f:selectItems value="#{searchBean.gameToSearch.cities}"/>
		    		</h:selectOneMenu>

	

				
				<h:commandButton value="Szukaj" action="#{searchBean.search}"/>

			


			<h:messages globalOnly="true" layout="table" />


			<h:panelGroup id="result">
				<h:dataTable binding="#{searchBean.scoreTable}" value="#{searchBean.games}" var="game"
					bgcolor="#F1F1F1" border="2" width="60%"  >
					
					        <h:column>
            <f:facet name="header">
                <h:outputText value="Select" />
            </f:facet>
            <h:selectOneRadio valueChangeListener="#{searchBean.setSelectedGameId}"
                onclick="scoreTableSelectOneRadio(this);">
                <f:selectItem itemValue="null" />
            </h:selectOneRadio>
        </h:column>
					
					<h:column>
						<f:facet name="header">Team A </f:facet>
						<h:outputText value="#{game.teamA}" />
					</h:column>

					<h:column>
						<f:facet name="header">Team B</f:facet>
						<h:outputText value="#{game.teamB}" />
					</h:column>

					<h:column>
						<f:facet name="header">City </f:facet>
						<h:outputText value="#{game.stadiumCity}" />
					</h:column>

					<h:column>
						<f:facet name="header">Stadium </f:facet>
						<h:outputText value="#{game.stadiumName}" />
					</h:column>

					
				</h:dataTable>
			</h:panelGroup>
			
			<h:commandButton value="Buy Ticket" action="#{searchBean.redirect}" rendered="#{userBean.logged}" />
		</h:form>
		<h:outputLabel value="You must log in to buy tickets" rendered="#{!userBean.logged}"/>
		</div>
		</ui:define>
		</ui:composition>
</html>